import os
import subprocess

os.system("clear")
def clear_screen():
    os.system('cls' if os.name == 'nt' else 'clear')

def list_directory():
    for item in os.listdir('.'):
        print(item)

def change_directory(path):
    try:
        os.chdir(path)
    except FileNotFoundError:
        print(f"Directory '{path}' Not Found")
    except NotADirectoryError:
        print(f"'{path}' Not a directory")

def show_help():
    print("Can Use Command:")
    print("  dir - List all files in the current directory")
    print("  cd <path> - Switch to the specified directory")
    print("  cls - clear the screen")
    print("  exit - Exit the GRUB Bootloader")
    print("  help - Show this help message")

def main():
    while True:
        command = input("GRUB> ").strip().lower()
        if command == 'dir':
            list_directory()
        elif command.startswith('cd '):
            path = command[3:].strip()
            change_directory(path)
        elif command == 'cls':
            clear_screen()
        elif command == 'exit':
            print("Exit...")
            break
        elif command == 'help':
            show_help()
        else:
            print(f"There is no such command: {command}")

if __name__ == "__main__":
    clear_screen()
    print("GRUB Bootloader v1.0")
    main()